changelog
	1.2
		minor bug with saving of global UI settings
		parsing for labels across windows and save files
		display size of patched code
		"insert directory" also processes subfolders
	1.1
		redone GUI with WinAPI
		exported code's font type and size to INI file
		load last file on startup
	1.0
		first release

                       Crappy RAM Assembly Patcher
                              version 1.2
                            by Lupus Erectus

I wrote this program to automate the process of assemblying ASM code and inserting
where it's needed. I needed it for PSX hacking but should be suitable to anything.

This is made in Game Maker 7.0 Pro (hence the size of the executable).

What it does:
  1- save your code to a user-defined text file
  2- run a user-defined command line (to run the assembler of your choice)
  3- insert an user-defined binary file (should be the result of the assembly) to
      another user-defined file (your ROM/RAM/whatever)

Settings:
All these file paths must be configured first in "crap.ini"
You must always use full paths, including the possible arguments to the value
"assembly_command".
The values under the "Assembly" section can be passed by command line; if you do
so, all of them must be passed.

Usage:
The org directive is mandatory; if it is missing, the code will be ignored.
You can have two files selected for inserting the code to. File 1 is the same for
all the open windows (use it for a ROM/RAM dump); File 2 can be chosen separately.
The insertion offset is NOT absolute: it is actually added to the org directive to
obtain the final insertion offset in the target file. For example, to insert in a
PSX RAM dump, set this value to -$80000000. Similarly, to insert in a PSX exe,
just set it to the file address in RAM (i.e. -$8000f800).
For the "org directive" and "insertion offset" textboxes, don't forget to use
"$" or "0x" to represent a hex value.
In the code textbox you can write what you want, it's your assembler's problem :p
The program will just add the org directive as "org "+string[org editbox] at the
beginning, before calling the assembler. Keep in mind that each textbox will be
sent to the assembler separately, so you can't i.e. use labels across them.
However I included some pre-assembly parsing to address this issue. See the
section below.

The code can be saved/loaded, and with it the files/addresses insertion settings.
With "Insert directory" you can insert all the saved code files from a folder in
one go (including subfolders).

The "Restore" feature allows you to undo an insertion. But it is not fool-proof,
so read ahead before you destroy all your hard work.
After an insertion the program remembers some values, not shown by the interface,
that can be used to revert the insertion: the offset in the target file and the
amount of bytes. These parameters are remembered separately for each textbox, and
for file [1] and [2], so nothing is ever lost. The "Restore" function uses them
to reinsert bytes from a previously selected file in the working file. So far so
good. You can undo an insertion immediately after you did it, without problems.
When saving code files, these parameters necessary for restoring, are also saved,
so you can load a code and undo it. But keep it mind that: 1) the restore data is
saved only when you click the save button; 2) the restore data is recalculated
only when you make an insertion. So it's possible that you end up saving restore
data incoherent with the actual code. If that concerns you, make sure to do an
insert before saving.

Parsing:
	"j label()" will search "label:" in all the open windows, including the
current one. "label()" will be replaced with the value of the ORG directive of the
windows where it's found, plus the number of the line multiplied by N (N is set in
the INI). Lines that are empty or containing only comments or tabs or spaces are
ignored.
Therefore, assembler directives and pseudo-instructions in the target textbox might
cause errors!
	"j label[]" will search "label:" in all the save files (*.csf) in the same
directory as the currently open file, other than in the open windows.
	Label declarations willl be searched at the beginning of lines (excluding
spaces and tabs) and must be followed by a ":"
	Everything after ";" is ignored by the parser.
	If it causes conflicts, the parser may be deactivated in the INI file.
